package col.edu.uniq.tiendamus.intprins;
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileNotFoundException;
import java.io.IOException;

import javax.swing.BorderFactory;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.border.SoftBevelBorder;
import javax.swing.SwingUtilities;

import org.ietf.jgss.Oid;



/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
/**
* esta es la interfaz principal
* donde estan todos los menus
* con un jTextField para comparar clave de administrador
* 	@author Diego Sanchez, David Giraldo, Angelica Soto
 *	@fecha 28 oct 2013
 *@version 2.0
*/
public class TiendaPrin extends javax.swing.JFrame implements ActionListener{
	private JMenuBar jMenuBPrin;
	private JMenu jMenu1;
	private JPanel jPanelPrins;
	private JMenuItem jMenuItemIngProd;
	private JMenuItem jMenuItemComFecha;
	private JMenuItem jMenuItemComClien;
	private JMenuItem jMenuItemListadProd;
	private JPasswordField jPasswordFClave;
	private JButton jBCompararClave;
	private JLabel jLClave;
	private JMenuItem jMenuItemPromos;
	private JMenu jMenuAdminis;
	private JMenuItem jMenuItemListas;
	private JCheckBoxMenuItem jCMenuItemRealizarC;
	private JButton jBSalir;
	private JMenu jMenurRComp;
	private JLabel jLImagenPrincipal;
	private JPanel jPanelExtras;
	private JMenuItem jMenuItemListaProd;
	private JMenuItem jMenuItemSelecPro;
	private JMenuItem jMenuItemInscrib;
	private JMenu jMenuInformes;
	private JMenu jMenuProduc;
	public Inscribete ins;
	public RealizarCompra listaComp;
	public Promociones prom;
	public Producto prod;
	public Tienda tienda=new Tienda();

//Auto-generated main method to display this JFrame

	public static void main(String[] args) {
		
		
		
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				TiendaPrin inst = new TiendaPrin();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public TiendaPrin() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setIconImage(new ImageIcon(getClass().getClassLoader().getResource("col/edu/uniq/tiendamus/intprins/musica.jpg")).getImage());

			{
				jPanelPrins = new JPanel();
				getContentPane().add(jPanelPrins, BorderLayout.CENTER);
				jPanelPrins.setBackground(new java.awt.Color(255,255,255));
				jPanelPrins.setLayout(null);
				{
					jPanelExtras = new JPanel();
					jPanelPrins.add(jPanelExtras);
					jPanelExtras.setBounds(0, 275, 439, 257);
					jPanelExtras.setLayout(null);
					{
						jBSalir = new JButton();
						jPanelExtras.add(jBSalir);
						jBSalir.setText("Salir");
						jBSalir.setBounds(301, 56, 87, 50);
						jBSalir.setFont(new Font("Cataneo BT",1,18));
						jBSalir.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								jBSalirActionPerformed(evt);
							}
						});
					}
					{
						jLClave = new JLabel();
						jPanelExtras.add(jLClave);
						jLClave.setText("Clave Adm");
						jLClave.setBounds(12, 21, 83, 16);
					}
					{
						jBCompararClave = new JButton();
						jPanelExtras.add(jBCompararClave);
						jBCompararClave.setText("Verificar");
						jBCompararClave.setFont(new Font("Cataneo BT",0,15));
						jBCompararClave.setBounds(257, 18, 134, 23);
						jBCompararClave.setSelected(true);
						jBCompararClave.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								jBCompararClaveActionPerformed(evt);
							}
						});
					}
					{
						jPasswordFClave = new JPasswordField();
						jPanelExtras.add(jPasswordFClave);
						jPasswordFClave.setBounds(95, 18, 135, 23);
					}
				}
				{
					jLImagenPrincipal = new JLabel();
					jPanelPrins.add(jLImagenPrincipal);
					jLImagenPrincipal.setBounds(0, 0, 439, 274);
					jLImagenPrincipal.setIcon(new ImageIcon(getClass().getClassLoader().getResource("col/edu/uniq/tiendamus/intprins/musica.jpg")));
				}

			}
			{
				jMenuBPrin = new JMenuBar();
				setJMenuBar(jMenuBPrin);
				jMenuBPrin.setBackground(new java.awt.Color(255,255,255));
				{
					jMenu1 = new JMenu();
					jMenuBPrin.add(jMenu1);
					jMenu1.setText("INSCRIBETE ");
					jMenu1.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0,0,0)));
					jMenu1.setFont(new Font("Cataneo BT",0,12));
					{
						jMenuItemInscrib = new JMenuItem();
						jMenu1.add(jMenuItemInscrib);
						jMenuItemInscrib.setText("Inscribete ya !");
						jMenuItemInscrib.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								jMenuItemInscribActionPerformed(evt);
							}
						});
					}
					jMenu1.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							jMenu1ActionPerformed(evt);
						}
					});
				}
				
				{
					jMenurRComp = new JMenu();
					jMenuBPrin.add(jMenurRComp);
					jMenurRComp.setText(" REALIZAR COMPRA ");
					jMenurRComp.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0,0,0)));
					jMenurRComp.setFont(new Font("Cataneo BT",0,12));
					{
						jCMenuItemRealizarC = new JCheckBoxMenuItem();
						jMenurRComp.add(jCMenuItemRealizarC);
						jCMenuItemRealizarC.setText("Comprar");
						jCMenuItemRealizarC.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								jCMenuItemRealizarCActionPerformed(evt);
							}
						});
					}
					jMenurRComp.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							jMenurRCompActionPerformed(evt);
						}
					});
				}
				{
					jMenuInformes = new JMenu();
					jMenuBPrin.add(jMenuInformes);
					jMenuInformes.setText(" INFORMES ");
					jMenuInformes.setFont(new Font("Cataneo BT",0,12));
					jMenuInformes.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0,0,0)));
					{
						jMenuItemListas = new JMenuItem();
						jMenuInformes.add(jMenuItemListas);
						jMenuItemListas.setText("Listar clientes");
						jMenuItemListas.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								jMenuItemListasActionPerformed(evt);
							}
						});
					}
					{
						jMenuItemListadProd = new JMenuItem();
						jMenuInformes.add(jMenuItemListadProd);
						jMenuItemListadProd.setText("Lista productos");
						jMenuItemListadProd.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								jMenuItemListadProdActionPerformed(evt);
							}
						});
					}
					{
						jMenuItemComClien = new JMenuItem();
						jMenuInformes.add(jMenuItemComClien);
						jMenuItemComClien.setText("Compras por cliente");
						jMenuItemComClien.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								jMenuItemComClienActionPerformed(evt);
							}
						});
					}
					{
						jMenuItemComFecha = new JMenuItem();
						jMenuInformes.add(jMenuItemComFecha);
						jMenuItemComFecha.setText("Compras por fecha");
						jMenuItemComFecha.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								jMenuItemComFechaActionPerformed(evt);
							}
						});
					}
					jMenuInformes.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							jMenuAdminActionPerformed(evt);
						}
					});
				}
				{
					jMenuAdminis = new JMenu();
					jMenuBPrin.add(jMenuAdminis);
					jMenuAdminis.setText(" ADMINISTRADOR");
					jMenuAdminis.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0,0,0)));
					{
						jMenuItemPromos = new JMenuItem();
						jMenuAdminis.add(jMenuItemPromos);
						jMenuAdminis.setEnabled(false);
						jMenuItemPromos.setText("Promociones");
						jMenuItemPromos.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								jMenuItemPromosActionPerformed(evt);
							}
						});
					}
					{
						jMenuItemIngProd = new JMenuItem();
						jMenuAdminis.add(jMenuItemIngProd);
						jMenuItemIngProd.setText("Ingresar productos");
						jMenuItemIngProd.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								jMenuItemIngProdActionPerformed(evt);
							}
						});
					}
				}
			}
			pack();
			this.setSize(455, 471);
			tienda.cargarClientes();
			tienda.cargarProductos();
		} catch (IOException e) {
		    JOptionPane.showMessageDialog(null, "No se encontro fichero de Registro de: "+e.getMessage(),"ADVERTENCIA", JOptionPane.WARNING_MESSAGE);
			e.printStackTrace();
		}catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	private void jMenu1ActionPerformed(ActionEvent evt) {
		System.out.println("jMenu1.actionPerformed, event="+evt);
		
	}
	
	private void jMenuProducActionPerformed(ActionEvent evt) {
		System.out.println("jMenuProduc.actionPerformed, event="+evt);
		//TODO add your code for jMenuProduc.actionPerformed
	}
	
	private void jMenurRCompActionPerformed(ActionEvent evt) {
		System.out.println("jMenurRComp.actionPerformed, event="+evt);
		//TODO add your code for jMenurRComp.actionPerformed
	}
	
	private void jMenuAdminActionPerformed(ActionEvent evt) {
		System.out.println("jMenuAdmin.actionPerformed, event="+evt);
		//TODO add your code for jMenuAdmin.actionPerformed
	}
	
	private void jMenuItemInscribActionPerformed(ActionEvent evt) {
		System.out.println("jMenuItemInscrib.actionPerformed, event="+evt);
		//TODO add your code for jMenuItemInscrib.actionPerformed
		ins=new Inscribete();
		ins.setVisible(true);
	}
	
	private void jMenuItemSelecProActionPerformed(ActionEvent evt) {
		
	}
	
	private void jMenuItemListaProdActionPerformed(ActionEvent evt) {
		System.out.println("jMenuItemListaProd.actionPerformed, event="+evt);
		
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	
	private void jBSalirActionPerformed(ActionEvent evt) {
		System.out.println("jBSalir.actionPerformed, event="+evt);
		System.exit(0);
	}
	
	private void jBRegistrarTPActionPerformed(ActionEvent evt) {
		System.out.println("jBRegistrarTP.actionPerformed, event="+evt);
		//TODO add your code for jBRegistrarTP.actionPerformed
	}
	
	private void jBBuscarCRTPActionPerformed(ActionEvent evt) {
		System.out.println("jBBuscarCRTP.actionPerformed, event="+evt);
		//TODO add your code for jBBuscarCRTP.actionPerformed
	}
	
	private void jCMenuItemRealizarCActionPerformed(ActionEvent evt) {
		System.out.println("jCMenuItemRealizarC.actionPerformed, event="+evt);
		listaComp=new RealizarCompra();
		listaComp.setVisible(true);
	}
	
	private void jMenuItemListasActionPerformed(ActionEvent evt) {
		
	}
	
	private void jMenuItemPromosActionPerformed(ActionEvent evt) {
		System.out.println("jMenuItemPromos.actionPerformed, event="+evt);
		prom=new Promociones();
		prom.setVisible(true);
	}
	
	private void jBCompararClaveActionPerformed(ActionEvent evt) {
		
	
		//aqui se le da una clave para poder acceder al menu administrador
		if(jPasswordFClave.getText().equals(tienda.getClave())){
			jMenuAdminis.setEnabled(true);
		}
		else{
			jMenuAdminis.setEnabled(false);
		}
		jPasswordFClave.setText("");
	}
	
	private void jMenuItemListadProdActionPerformed(ActionEvent evt) {
		System.out.println("jMenuItemListadProd.actionPerformed, event="+evt);
		//TODO add your code for jMenuItemListadProd.actionPerformed
	}
	
	private void jMenuItemComClienActionPerformed(ActionEvent evt) {
		System.out.println("jMenuItemComClien.actionPerformed, event="+evt);
		//TODO add your code for jMenuItemComClien.actionPerformed
	}
	
	private void jMenuItemComFechaActionPerformed(ActionEvent evt) {
		System.out.println("jMenuItemComFecha.actionPerformed, event="+evt);
		//TODO add your code for jMenuItemComFecha.actionPerformed
	}
	
	private void jMenuItemIngProdActionPerformed(ActionEvent evt) {
		
		prod=new Producto();
		prod.setVisible(true);
	}

}
